home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!bnelson
- From: bnelson@netcom.com (Bob Nelson)
- Subject: Pohl's "C++ for C Programmers"
- Message-ID: <bnelsonDnEH5y.Ax0@netcom.com>
- Organization: a computer running Linux
- X-Newsreader: TIN [version 1.2 PL2]
- Date: Mon, 26 Feb 1996 20:34:45 GMT
- Sender: bnelson@netcom6.netcom.com
-
- As a longtime C programmer now trying to learn C++, I am using Ira
- Pohl's "C++ for C Programmers" as my iniitial guide to the language.
-
- I am currently stalled because of an issue found in the section
- dealing with constructors and destructors, chapter 1.6, (p. 21-22).
- NOTE: You'll need to reference that section to follow th rest of this
- posting.
-
- In particular, Pohl introduces a dynamic storage scheme for the
- storage of an array of characters. Prior to this point, the
- string's characters were stored in a fixed array.
-
- Tied into this is the overloaded '+' operator used to concatenate
- two string-type objects. Naturally, it worked as expected when
- the class used a fixed array for storage. Once the fixed array
- became a dynamic object, the concatentation '+' operator ceased
- to work -- which seems only natural since the destructor does
- destroy the storage area prior to the assignment of the temporary.
- In particular, g++ 2.7.2 (under Linux) returns either an empty
- string or a few random trash characten using the concatention operator.
-
- I note that Pohl mentions nothing about a possible change that may
- need to be made to the the operator routine when the fixed array is
- replaced by dynamic storage. (See the class declaration on page 21
- and his defintion of the overloaded '+' function on page 18).
-
- What changes, if any, do need to be made to permit the concatenation
- operator when the fixed array is replaced by dynamic storage?
-
- --
- =============================================================================
- Bob Nelson: Dallas, Texas, U.S.A. - bnelson@netcom.com
- Linux for fun, M$ for $$$...and the NFL for what really counts!
- =============================================================================
-
-